import {defineStore} from 'pinia'
import {userInfoApi} from '@/api/user'
import {getToken} from "@/utils/auth"

export const useUserStore = defineStore('user', {
    state: () => ({
        token: getToken(),
        userInfo: {}
    }),
    actions: {
        getUserInfo() {
            return new Promise((resolve, reject) => {
                userInfoApi().then((res) => {
                    this.userInfo = res.data || {}
                    resolve()
                })
            })
        }
    },
})
